﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Dotnet.Samples.Avalon" x:Class="Dotnet.Samples.Avalon.CipherView" Title="Dotnet.Samples.Avalon" Width="640" MinWidth="480" MaxWidth="1280" Height="320" MinHeight="320" MaxHeight="320" Icon="/res/VisualStudio.ico" Name="RijndaelWindow">
    <Window.Resources>
        <local:CipherViewModel x:Key="CipherViewModel" />
        <Style TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid Name="RijndaelGrid" Margin="8" ShowGridLines="False" Height="Auto" Width="Auto" DataContext="{StaticResource CipherViewModel}" VerticalAlignment="Center">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Margin="8,16,8,0" Text="Windows Presentation Foundation (WPF)" FontSize="16" FontWeight="SemiBold" TextAlignment="Center" />
        <Grid Grid.Row="1" Name="InputOutputGrid" Margin="0,8,0,0" ShowGridLines="False" Width="Auto" Height="Auto" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <GroupBox Grid.Column="0" Name="InputGroupBox" Header="Input" Width="Auto" Height="Auto" Margin="8" VerticalAlignment="Top">
                <TextBox Name="InputTextBox" MinWidth="128" MinHeight="24" MaxHeight="24" Margin="8" VerticalAlignment="Top" Text="{Binding Plaintext, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsInputEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
            </GroupBox>
            <GroupBox Grid.Column="1" Name="OutputGroupBox" Header="Output" Width="Auto" Height="Auto" Margin="8" VerticalAlignment="Top">
                <TextBox Name="OutputTextBox" MinWidth="128" MinHeight="24" MaxHeight="24" Margin="8" VerticalAlignment="Top" Text="{Binding Ciphertext, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsOutputEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
            </GroupBox>
        </Grid>
        <GroupBox Grid.Row="2" Name="SettingsGroupBox" Margin="8" Header="Settings" Width="Auto" Height="Auto" VerticalAlignment="Top">
            <Grid Name="SettingsGrid" ShowGridLines="False" Width="Auto" VerticalAlignment="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0" Name="SettingsGridLeft" ShowGridLines="False" Margin="0,8,16,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" Name="PassphraseTextBlock" Text="Passphrase" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" TextAlignment="Right" />
                    <TextBox Grid.Column="1" Grid.Row="0" Name="PassphraseTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Background="White" Text="{Binding Passphrase, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
                </Grid>
                <Grid Grid.Column="1" Name="SettingsGridRight" ShowGridLines="False" Margin="16,8,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" Name="SaltTextBlock" Text="Salt" Width="Auto" Height="24" Margin="8" TextAlignment="Right" />
                    <TextBox Grid.Column="1" Grid.Row="0" Name="SaltTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Background="White" Text="{Binding Salt, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
                </Grid>
            </Grid>
        </GroupBox>
        <StackPanel Grid.Row="3" Name="EncryptDecryptStackPanel" Margin="0,0,0,16" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Name="EncryptButton" Margin="8" Width="64" Height="32" Content="Encrypt" Command="{Binding Encrypt}">
                <Button.ToolTip>
                    <ToolTip>
                        <StackPanel>
                            <TextBlock FontWeight="Bold">
                                Encrypt Input
                            </TextBlock>
                            <TextBlock>
                                Dotnet.Samples.Avalon
                            </TextBlock>
                        </StackPanel>
                    </ToolTip>
                </Button.ToolTip>
            </Button>
            <Button Name="DecryptButton" Margin="8" Width="64" Height="32" Content="Decrypt" Command="{Binding Decrypt}">
                <Button.ToolTip>
                    <ToolTip>
                        <StackPanel>
                            <TextBlock FontWeight="Bold">
                                Decrypt Output
                            </TextBlock>
                            <TextBlock>
                                Decrypts ciphertext output value using Advanced Encryption Standard (Rijndael)
                            </TextBlock>
                        </StackPanel>
                    </ToolTip>
                </Button.ToolTip>
            </Button>
        </StackPanel>
    </Grid>
    <Window.Background>
        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="White" Offset="0.15" />
            <GradientStop Color="#FF525552" Offset="5" />
        </LinearGradientBrush>
    </Window.Background>
</Window>